//
// Created by 123 on 2024/12/27.
//
#include "stdio.h"

int main079(){
    FILE* fp;
    char ch;
    //以文本读取
    fp = fopen("rewind.txt","r");
    if(fp == NULL){
        perror("open error");
        return 1;
    }
    //读取前三个字符
    for (int i = 0; i < 3; ++i) {
        ch = fgetc(fp);
        if(ch == EOF){
            break;
        }
        putchar(ch);
    }
    printf("\n");
    //获取当前文件指针的位置
    long pos = ftell(fp);
    printf("current pos:%d\n",pos);
    //重置文件指针的位置
    rewind(fp);
    //再次读取
    while ((ch = fgetc(fp)) != EOF){
        putchar(ch);
    }
    fclose(fp);

    return 0;
}